inspector: Fix property list styling
authorMatthias Clasen <mclasen@redhat.com>
Tue, 7 Jul 2020 06:12:30 +0000 (02:12 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 7 Jul 2020 15:21:42 +0000 (11:21 -0400)
We use dropdowns here now, so style them.

Also, avoid the swoosh when switching to the
property list, when everything shrinks.

gtk/inspector/inspector.css
gtk/inspector/prop-list.c
gtk/inspector/prop-list.ui

index 857fb2f8cee316b86e09e6f45ce3b9dcd6bade07..920a7cceea9020398b09a3e27ed2ea1ccd6cf3e7 100644 (file)
@@ -35,6 +35,7 @@
 .list .cell entry,
 .list .cell spinbutton,
 .list .cell button,
+.list .cell dropdown
 .list .cell combobox {
   min-height: 24px;
   min-width: 0;
@@ -42,6 +43,7 @@
 
 .list .cell entry,
 .list .cell button,
+.list .cell dropdown
 .list .cell combobox {
   padding: 0 4px;
 }
index e3f4668d291949d8c4d025f6e6e9f4cb605e1f39..5c5a2c5e33da3855f001cdd6a029fc091088b80b 100644 (file)
@@ -381,12 +381,25 @@ bind_origin_cb (GtkSignalListItemFactory *factory,
   gtk_label_set_label (GTK_LABEL (label), origin);
 }
 
+static void
+setup_value_cb (GtkSignalListItemFactory *factory,
+                GtkListItem              *list_item,
+                gpointer                  data)
+{
+  GtkWidget *widget;
+
+  widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_widget_add_css_class (widget, "cell");
+  gtk_list_item_set_child (list_item, widget);
+}
+
 static void
 bind_value_cb (GtkSignalListItemFactory *factory,
                GtkListItem              *list_item,
                gpointer                  data)
 {
   GObject *item;
+  GtkWidget *editor;
   GtkWidget *widget;
   GObject *object;
   const char *name;
@@ -396,10 +409,10 @@ bind_value_cb (GtkSignalListItemFactory *factory,
   object = prop_holder_get_object (PROP_HOLDER (item));
   name = prop_holder_get_name (PROP_HOLDER (item));
 
-  widget = gtk_inspector_prop_editor_new (object, name, NULL);
-  g_signal_connect (widget, "show-object", G_CALLBACK (show_object), data);
-  gtk_list_item_set_child (list_item, widget);
-  gtk_widget_add_css_class (widget, "cell");
+  editor = gtk_inspector_prop_editor_new (object, name, NULL);
+  g_signal_connect (editor, "show-object", G_CALLBACK (show_object), data);
+  widget = gtk_list_item_get_child (list_item);
+  gtk_box_append (GTK_BOX (widget), editor);
 }
 
 static void
@@ -407,7 +420,10 @@ unbind_value_cb (GtkSignalListItemFactory *factory,
                  GtkListItem              *list_item,
                  gpointer                  data)
 {
-  gtk_list_item_set_child (list_item, NULL);
+  GtkWidget *widget;
+
+  widget = gtk_list_item_get_child (list_item);
+  gtk_box_remove (GTK_BOX (widget), gtk_widget_get_first_child (widget));
 }
 
 static void
@@ -441,6 +457,7 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, bind_type_cb);
   gtk_widget_class_bind_template_callback (widget_class, setup_origin_cb);
   gtk_widget_class_bind_template_callback (widget_class, bind_origin_cb);
+  gtk_widget_class_bind_template_callback (widget_class, setup_value_cb);
   gtk_widget_class_bind_template_callback (widget_class, bind_value_cb);
   gtk_widget_class_bind_template_callback (widget_class, unbind_value_cb);
 }
index 9c952c3f41ca340797ae256d41da7f5776360f24..15ccf2e2e9cbb73bad154814e5084af883a2ddf6 100644 (file)
@@ -57,6 +57,7 @@
                     <property name="expand">1</property>
                     <property name="factory">
                       <object class="GtkSignalListItemFactory">
+                        <signal name="setup" handler="setup_value_cb"/>
                         <signal name="bind" handler="bind_value_cb"/>
                         <signal name="unbind" handler="unbind_value_cb"/>
                       </object>